<template>
    <div>
        <Form :model="form" label-position="left" :label-width="100">
            <FormItem label="填报部门"  prop="title" >
                <Input v-model="form.bmA" style="width: 25%;" disabled></Input>
            </FormItem>
            <FormItem label="月度"  prop="title" >
                <Input v-model="form.dated" style="width: 25%;" disabled></Input>
            </FormItem>
        </Form>
        <Form :model="formItem">
            <FormItem style="float:left;width: 100%">
                <Alert type="warning" style="width: 100%">
                    <Icon type="ios-warning-outline" /><label><b>填写说明</b></label><br>
                    <p style="margin-top: 10px;margin-left: 25px">纪检组（单位纪委）组织会议推动体系建设次数：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">其中纪检组长（单位纪委书记）组织召开会议次数：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">专项监督数量（个）：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">专项监督涉及资金量（万元）：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">疑似问题数量（个）：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">核实问题数量（个）：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">问责处置人数：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">其中1：批评教育、诫勉谈话、组织调整人数：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">其中2：党纪政务处分人数：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">其中3：移送司法人数：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">每年可节约资金或避免经济损失（万元）：是指_ _ _ _ _ _ _ _ _ _ _</p>
                    <p style="margin-top: 10px;margin-left: 25px">开展体系建设以来已挽回经济损失（万元）：是指_ _ _ _ _ _ _ _ _ _ _</p>
                </Alert>
                <Row :gutter="16" style="padding-top: 10px">
                    <Col span="8"><Input v-model="formItem.discipline_inspection_num" type="number">
                        <span slot="prepend">纪检组（单位纪委）组织会议推动体系建设次数</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.discipline_inspection_meeting_num" type="number">
                        <span slot="prepend">其中纪检组长（单位纪委书记）组织召开会议次数</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.special_num" type="number">
                        <span slot="prepend">专项监督数量（个）</span>
                    </Input></Col>
                </Row>
                <Row :gutter="16" style="padding-top: 20px">
                    <Col span="8"><Input v-model="formItem.special_money" type="number">
                        <span slot="prepend">专项监督涉及资金量（万元）</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.suspected_problems_num" type="number">
                        <span slot="prepend">疑似问题数量（个）</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.problem_num" type="number">
                        <span slot="prepend">核实问题数量（个）</span>
                    </Input></Col>
                </Row>
                <Row :gutter="16" style="padding-top: 20px">
                    <Col span="8"><Input v-model="formItem.accountability_num" type="number">
                        <span slot="prepend">问责处置人数</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.among_one" type="number">
                        <span slot="prepend">其中1：批评教育、诫勉谈话、组织调整人数</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.among_two" type="number">
                        <span slot="prepend">其中2：党纪政务处分人数</span>
                    </Input></Col>
                </Row>
                <Row :gutter="16" style="padding-top: 20px">
                    <Col span="8"><Input v-model="formItem.among_three" type="number">
                        <span slot="prepend">其中3：移送司法人数</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.save_money" type="number">
                        <span slot="prepend">每年可节约资金或避免经济损失（万元）</span>
                    </Input></Col>
                    <Col span="8"><Input v-model="formItem.salvation_money" type="number">
                        <span slot="prepend">开展体系建设以来已挽回经济损失（万元）</span>
                    </Input></Col>
                </Row>
            </FormItem>
            <FormItem label="附件上传">
                <Row :gutter="16">
                    <Col>
                        <wl-upload-oss-files
                                v-model="formItem.file_text"
                                :maxNum="1"
                                uploadType="hadoop"
                                uploadStyle="other"
                                uploadUrl='http://218.60.17.11:33685/api/ac/file/fileCommonService/upLoadFiles'
                                getSignUrl="/api/ac/jwork/getHadoopService/getSign"
                                fileName="origin"
                                :beforeUploadFilter="uploadFilter"
                                :format="['doc','docx']"
                                fileDir="/jov/">
                        </wl-upload-oss-files>
                    </Col>
                </Row>
                <Row :gutter="16">
                    <Col style="margin-left:65px">请上传节约、避免、挽回经济损失的文字说明材料，格式为Word文档</Col>
                </Row>
            </FormItem>
            <FormItem style="margin-top: 30px">
                <Row :gutter="16">
                    <Col span="19">
                        <div style="margin-bottom: -8%;width: 30px;text-align: center">备注</div>
                        <Input v-model="formItem.remarks" type="textarea" :autosize="{minRows: 5,maxRows: 5}" maxlength="500" show-word-limit style="margin-left: 10%;width: 60%;margin-top: 50px">
                        </Input>
                    </Col>
                </Row>
            </FormItem>
            <Row type="flex" justify="center" class="code-row-bg" style="margin-top: 20px">
                <Col>
                    <Button type="success" @click="submit()">提报</Button>
                </Col>
            </Row>
            <Row type="flex" justify="center" class="code-row-bg" style="margin-top: 20px">
                <Col>
                    <span>纪检组情况统计信息可多次提报</span>
                </Col>
            </Row>
        </Form>
    </div>
</template>

<script>
import { insertZlDiscipline, getZlDisciplineByCodeList } from '@/api/user'
// getZlDisciplineByCodeList
export default {

  name: 'test',

  data () {
    return {
      month: '',
      form: {
        bmA: '',
        dated: ''
      },
      formItem: {
        discipline_inspection_num: '',
        discipline_inspection_meeting_num: '',
        special_num: '',
        special_money: '',
        suspected_problems_num: '',
        problem_num: '',
        accountability_num: '',
        among_one: '',
        among_two: '',
        among_three: '',
        save_money: '',
        salvation_money: '',
        file_text: '',
        remarks: ''
      }
    }
  },

  props: {

  },

  components: {

  },

  computed: {

  },

  methods: {
    async init () {
      var myDate = new Date()
      myDate.getFullYear() // 获取完整的年份(4位,1970-????)
      myDate.getMonth() // 获取当前月份(0-11,0代表1月)
      let y = myDate.getFullYear()
      let d = myDate.getMonth()
      if (d < 10) {
        d = '0' + d
      }
      let yd = y + '年' + d + '月'
      this.form.dated = yd
      this.month = y + '-' + d
      if (this.$route.query.para !== undefined) {
        this.formItem = this.$route.query.para
        this.form.bmA = this.$route.query.para.department_name
      } else {
        this.form.bmA = this.$store.state.user.severUserInfo.data.company_name
      }
      getZlDisciplineByCodeList().then(ret => {
        if (ret.data.errcode === 0) {
          if (ret.data.data !== '' || ret.data.data !== undefined) {
            this.formItem.discipline_inspection_num = ret.data.data[0].discipline_inspection_num
            this.formItem.discipline_inspection_meeting_num = ret.data.data[0].discipline_inspection_meeting_num
            this.formItem.special_num = ret.data.data[0].special_num
            this.formItem.special_money = ret.data.data[0].special_money
            this.formItem.suspected_problems_num = ret.data.data[0].suspected_problems_num
            this.formItem.problem_num = ret.data.data[0].problem_num
            this.formItem.accountability_num = ret.data.data[0].accountability_num
            this.formItem.among_one = ret.data.data[0].among_one
            this.formItem.among_two = ret.data.data[0].among_two
            this.formItem.among_three = ret.data.data[0].among_three
            this.formItem.save_money = ret.data.data[0].save_money
            this.formItem.salvation_money = ret.data.data[0].salvation_money
            this.formItem.file_text = ret.data.data[0].file_text
            this.formItem.remarks = ret.data.data[0].remarks
          } else {

          }
        } else {
          this.$Message.error('数据加载失败！！！！' + ret.data.errmsg)
        }
        console.log(ret, 'ret!!!!!')
      })
    },
    submit (nodesc) {
      if (this.formItem.id === undefined) {
        this.formItem.monthly = this.month
        insertZlDiscipline(this.formItem).then(ret => {
          if (ret.data.errcode === 0) {
            this.$Message.success('提报成功')
            this.$router.push({
              name: 'disciplineInspections'
            })
          } else {
            this.$Notice.error({
              title: '填报失败',
              desc: nodesc ? '' : '一个用户每月只能填报一条数据！！！！！！'
            })
          }
        })
      } else {
        this.formItem.id = this.$route.query.para.id
        this.formItem.monthly = this.month
        insertZlDiscipline(this.formItem).then(ret => {
          // console.log(ret.data.errmsg, '!!!!!!!!@@@@@@@')
          if (ret.data.errcode === 0) {
            this.$Message.success('修改成功')
            this.$router.push({
              name: 'disciplineInspections'
            })
          } else {
            this.$Message.error('修改失败' + ret.data.errmsg)
          }
        })
      }
    },
    uploadFilter (file, uploadList, filterReturn) {
      console.log(this.url, 'uploadList')
      let isExit = false
      if (uploadList.length > 0) {
        uploadList.forEach(item => {
          if (item.url.indexOf(file.name) !== -1) {
            isExit = true
          }
        })
      }
      if (isExit) {
        this.errMsgAction(file.name, '【文件已经存在】')
        return { errcode: false, selfShow: true }
      }
      return { errcode: true }
    }
  },

  watch: {

  },

  mounted () {
    this.init()
  }

}
</script>

<style scoped>

</style>
